package cn.hyh.core.controller;

import cn.hyh.core.pojo.Msg;
import cn.hyh.core.service.ServiceInterface.MsgService;
import cn.hyh.core.vo.ResultVo;
import cn.hyh.core.vo.MsgModel;
import cn.hyh.core.vo.PageModel;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @auther :hyh
 * @desc :
 * @date :2019/7/15
 */
@RestController
@RequestMapping("/msg")
public class MsgController {

    @Resource
    private MsgService msgService;

    /**
     *
     * @return
     */
     @RequestMapping(value = "/saveVisitorMsg",method = RequestMethod.POST)
    public Map<String,Object> saveVisitorMsg(@RequestBody MsgModel model, HttpServletRequest request){
       Msg msg= msgService.saveMsg(model,request);

         return ResultVo.successResult(msg);
     }

     @RequestMapping(value = "/saveChildReply",method = RequestMethod.POST)
    public  Map<String,Object>  saveChildReply(@RequestBody MsgModel model,HttpServletRequest request) {
         Msg msg= msgService.saveMsg(model,request);
         return ResultVo.successResult(msg);
     }


    /**
     * 分页查询 历史记录。
     * @return
     */
     @RequestMapping(value = "/getMsgHistoryPage",method = RequestMethod.POST)
      public  Map<String,Object>  MsgHistoryPage(@RequestBody PageModel model){
         Map<String, Object> pageMap = msgService.getPageList(model);
         return ResultVo.successResult(pageMap);
     }


    /**
     * 获取文章的历史评论。
     * @param id
     * @return
     */
    @RequestMapping(value = "/articleCommentList", method = RequestMethod.POST)
    public Map<String, Object> articleCommentList(@RequestParam("id") int id) {
        List<Msg> list = msgService.articleCommentList(id);
        return ResultVo.successResult(list);

    }




}
